home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / projectCurvePreset.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.7 KB  |  174 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  April 1, 1997
  22. //  Author:        RS 
  23. //
  24. //  Description:
  25. //      The projectCurvePreset() procedure executes project curve operation. 
  26. //
  27. //  Input Arguments:
  28. //      None.
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34. // currentView -q -c 
  35. //  gives the current camera.
  36. //
  37.  
  38. proc string pieceTogetherCmd(
  39.     int $doHistory,
  40.     int $curvePartial,
  41.     int $viewDir,
  42.     float $tol )
  43. //
  44. //    Description :
  45. //        Put together a projectCurve  Cmd.
  46. //
  47. {
  48.     string $cmd = "projectCurve" ;
  49.  
  50.     // history.
  51.     //
  52.     $cmd = $cmd + " -ch " ;
  53.     if( $doHistory == 1 ) $cmd = $cmd + "true" ;    
  54.     else $cmd = $cmd + "false" ;
  55.  
  56.     // curve range.
  57.     //
  58.     $cmd = $cmd + " -rn " ;
  59.     if( $curvePartial == 1 ) $cmd = $cmd + "true" ;
  60.     else $cmd = $cmd + "false" ;
  61.  
  62.     // projection direction 
  63.     //
  64.     $cmd = $cmd + " -un " ;
  65.     if( $viewDir == 1 ) {
  66.         $cmd = $cmd + " true " ;
  67.     } else {
  68.         $cmd = $cmd + " false " ;
  69.     }
  70.  
  71.     $cmd = $cmd + " -tol " + $tol ;
  72.  
  73.     return $cmd ;
  74. }
  75.  
  76. global proc projectCurvePreset(
  77.     int $doHistory,
  78.     int $curvePartial,
  79.     int $viewDir,
  80.     float $tol ) 
  81. //
  82. //    Description :
  83. //        Proc to do a bevel 
  84. //
  85. {
  86.  
  87.     //---------------------------------------------
  88.     // Get the list of nurbs curves to be projected
  89.     // from the select list. 
  90.     //---------------------------------------------
  91.     //
  92.     global int $gSelectNurbsCurvesBit;
  93.     global int $gSelectIsoparmsBit;
  94.     global int $gSelectCurvesOnSurfacesBit;
  95.     global int $gSelectSurfaceEdgeBit;
  96.     global int $gSelectNurbsSurfacesBit;
  97.     global int $gSelectMeshEdge;
  98.  
  99.     string $curveList[] = `filterExpand -ex true -sm $gSelectNurbsCurvesBit -sm $gSelectIsoparmsBit -sm $gSelectMeshEdge -sm $gSelectCurvesOnSurfacesBit -sm $gSelectSurfaceEdgeBit`;
  100.  
  101.     string $srfList[] = `filterExpand -ex true -sm $gSelectNurbsSurfacesBit` ;
  102.  
  103.  
  104.     // NOTE : We do the piecing together after the filters. Why ?
  105.     // If the project direction is based on the view camera, because
  106.     // of the way the current view direction is determined we want
  107.     // to ensure the selection list is NOT lost.
  108.     //
  109.  
  110.     //---------------------------------------
  111.     // put together a projectCurve cmd.
  112.     //---------------------------------------
  113.     //
  114.     string $cmd = pieceTogetherCmd(    $doHistory, 
  115.                                     $curvePartial,
  116.                                     $viewDir,
  117.                                     $tol ) ;
  118.  
  119.     //----------------------------------------
  120.     // place holders for 1 selection items.
  121.     //----------------------------------------
  122.     //
  123.     int $nitems = 2 ;
  124.     $cmd = appendToCmdPlaceHoldersForSelectionItems($cmd,$nitems) ;
  125.     
  126.  
  127.     //--------------------------------------------
  128.     // Valid # of items.
  129.     //--------------------------------------------
  130.     //
  131.  
  132.  
  133.     int $curveCount = size($curveList) ;
  134.     int $srfCount = size($srfList) ;
  135.     if( $curveCount == 0 ) {
  136.        error "Select at least one curve to project" ; 
  137.     } else if( $srfCount == 0 ) {
  138.        error "Select at least one NURBS surface to project on to" ; 
  139.     } else {
  140.  
  141.         ////////////////////////////////////////////////////////////
  142.         // n curves & m surfaces gives n*m project curve operations. 
  143.         ////////////////////////////////////////////////////////////
  144.         //
  145.         string $pair[2] ;
  146.         string $projectResults[] ;
  147.         int $i, $j ;
  148.         for( $i = 0 ; $i < $curveCount ; $i++ ) {
  149.             $pair[0] = $curveList[$i] ;
  150.             for( $j = 0 ; $j < $srfCount ; $j++ ) {
  151.                 $pair[1] = $srfList[$j] ;
  152.                 string $results[] = executeCmdOnItems($cmd,$pair);    
  153.                 $projectResults = stringArrayCatenate($projectResults, $results);
  154.             } // for $j.
  155.         } // for $i.    
  156.  
  157.         int $resultCount = size($projectResults) ;
  158.  
  159.         if( $resultCount > 0 ) {
  160.             string $selectString;
  161.             $selectString = "select -r ";
  162.  
  163.             for( $i = 0 ; $i < $resultCount ; $i++ ) {
  164.                 $selectString +=  $projectResults[$i] ;
  165.                 $selectString += " ";    
  166.             }
  167.  
  168.             $selectString += ";" ;
  169.             eval($selectString) ;
  170.         }
  171.     }
  172. }
  173.  
  174.